<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<base href='<?php echo base_url()?>'>
<link rel="stylesheet" type="text/css" href="public/common/css/common.css"/>
<link rel="stylesheet" type="text/css" href="public/admin/css/admin.css"/>
<script src="public/common/js/jquery.js"></script>
<script>
$(function(){
	table_show(0);	

	$('.tab ul li').each(function(index){
		$(this).click(function(){
			$('.tab ul li').removeClass('cur');	
			$(this).addClass('cur');
			table_show(index);
		});										  
	});	  
	
	$('input[name="category_tpl"]').click(function(){
		tr_length = $(this).parent().parent().nextAll('tr').length;
		if($(this).val() == '2')
		{
			if(tr_length < 2)
			{
				html = '<tr><td class="center">外部链接地址：</td><td><input type=text name="category_tpl_out" value="http://"></td><td><span class="red">*</span> 地址可以是完整的URL地址，也可以是本地php文件</td></tr>';
				$(this).parent().parent().after(html);
			}	
		}else{
			if(tr_length > 1)
			{
				$(this).parent().parent().next('tr').remove();
			}
		}
	});
	change_tpl();

	$('select[name="model_id"]').val('<?php echo $category->model_id?>');
})
function table_show(index)
{
	$('.table').hide();
	$('.table:eq('+index+')').show();
}
function change_tpl()
{
	$('.tpl_list input[name="tpl_list"]').val($('.tpl_list input:hidden').eq(Number($('select[name="model_id"]').val())-1).val());
	$('.tpl_content input[name="tpl_content"]').val($('.tpl_content input:hidden').eq(Number($('select[name="model_id"]').val())-1).val());
}
</script>
</head>
<body>
	<div id="sys">
	    <div class="main_top"><div class="position left">当前位置 <span>&gt;</span> 栏目 <span>&gt;</span> 网站栏目 <span>&gt;</span> 管理栏目 <span>&gt;</span> 修改栏目 </div></div>
        <div class="go_back"><a href="javascript:history.back()">返回</a></div>
   		<div class="sys_center">
        	<div class="tab left">
            	<ul>
                	<li class="cur">基本设置</li>
                    <li>高级设置</li>
                </ul>
            </div>
            <div class="clear"></div>
            <div class="tab_content">
  
          		<!-- 基本设置 start -->
                <form action="<?php echo site_url('admin/category/edit_category/'.$category->category_id)?>" method="post">
            	<table class="table">
                	<tr><th>参数名</th><th>参数值</th><th style='width:400px;'>参数说明</th></tr>
					<tr>
						<td class='center'>内容模型：</td>
						<td>
							<select name='model_id' onchange='change_tpl()'>
								<?php if($model):?>
	            					<?php foreach($model->result() as $value):?>
	            					<option value='<?php echo $value->model_id?>'><?php echo $value->model_name?></option>
	           					 	<?php endforeach;?>
	           					 <?php else:?>
	            					<option value='0'>没有数据</option>
            					<?php endif; ?>
							</select>
						</td>
						<td><span class='red'>*</span> 首页具体显示是哪个页面是根据模型来判断的</td>
					</tr> 
					<tr>
						<td class='center'>栏目名称：</td>
						<td><input type=text name='category_name' value='<?php echo $category->category_name?>'></td>
						<td><span class='red'>*</span> 首页显示的栏目名称</td>
					</tr>
					<tr>
						<td class='center'>栏目排序：</td>
						<td><input type=text name='category_sort' value='<?php echo $category->category_sort?>'></td>
						<td><span class='red'>*</span> 栏目排序(由小到大)</td>
					</tr>
					<tr>
						<td class='center'>导航显示：</td>
						<td>
							<input type=checkbox name='category_display_top' value='1' <?php if($category->category_display_top == '1'):?>checked<?php endif;?>>顶部显示
							<input type=checkbox name='category_display_bottom' value='1' <?php if($category->category_display_bottom == '1'):?>checked<?php endif;?>>底部显示
						</td>
						<td><span class='red'>*</span> 不勾选，表示顶部和底部都不显示</td>
					</tr>
					<tr>
						<td class='center'>栏目页面类型：</td>
						<td>
							<input type=radio name='category_tpl' value='1' <?php if($category->category_tpl == '1'):?>checked<?php endif;?>>列表页面
							<input type=radio name='category_tpl' value='2' <?php if($category->category_tpl == '2'):?>checked<?php endif;?>>外部链接
						</td>
						<td><span class='red'>*</span> 如果选择外部链接，那么点击此栏目将会链接到其他网站</td>
					</tr>

                     <tr><td>&nbsp;</td><td colspan="2"><input type="submit" name="submit" class="submit" value="提交" /> &nbsp;&nbsp;<input type="reset" name="reset" class="reset" value="重置" /></td></tr>
                </table>
                <!-- 基本设置 end -->
                
                <!-- 高级设置 start -->
                <table class="table">
					 <tr><th>参数名</th><th>参数值</th><th style='width:400px;'>参数说明</th></tr>
					 <tr>
						<td class='center'>是否新窗口：</td>
						<td>
							<input type=radio name='category_open' value='1' <?php if($category->category_open == '1'):?>checked<?php endif;?>>是
							<input type=radio name='category_open' value='0' <?php if($category->category_open == '0'):?>checked<?php endif;?>>否
						</td>
						<td><span class='red'>*</span> 点击栏目时，是否是新窗口打开页面</td>
					</tr>
					<tr>
						<td class='center'>列表页显示数量：</td>
						<td>
							<input type=text name='tpl_list_num' value='<?php echo $category->tpl_list_num?>'>
						</td>
						<td><span class='red'>*</span> 仅对页面类型为列表页时有效</td>
					</tr>
					<tr>
						<td class='center'>列表页模板：</td>
						<td class='tpl_list'>
							<?php if($model):?>
	            				<?php foreach($model->result() as $value):?>
	            					<input type=hidden value='<?php echo $value->list_tpl?>'>
	           					 <?php endforeach;?>
	           				 <?php else:?>
	            					<input type=hidden value=''>
            				<?php endif; ?>
							<input type=text name='tpl_list' value=''>
						</td>
						<td><span class='red'>*</span> 仅对页面类型为列表页时有效</td>
					</tr>
					<tr>
						<td class='center'>内容页模板：</td>
						<td class='tpl_content'>
							<?php if($model):?>
	            				<?php foreach($model->result() as $value):?>
	            					<input type=hidden value='<?php echo $value->content_tpl?>'>
	           					 <?php endforeach;?>
	           				 <?php else:?>
	            					<input type=hidden value=''>
            				<?php endif; ?>
							<input type=text name='tpl_content' value=''>
						</td>
						<td><span class='red'>*</span> 仅对页面类型为列表页时有效</td>
					</tr>
                     <tr><td align="center" colspan="2"><input type="submit" name="submit" class="submit" value="提交" /> &nbsp;&nbsp;<input type="reset" name="reset" class="reset" value="重置" /></td><td>&nbsp;</td></tr>
                </table>
                </form>
                <!-- 高级设置 end -->
            </div>
        </div>
    </div>
</body>
</html>